package com.example.farmer.Adapter.Product;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.farmer.Fragment.Buyer_Home.FruitsFragment;
import com.example.farmer.Fragment.Buyer_Home.SeedFragment;
import com.example.farmer.Fragment.Buyer_Home.VegetableFragment;
import com.example.farmer.Fragment.Home.Buyer_HomeFragment;

import java.util.List;

public class ViewPagerProductAdapter extends FragmentStateAdapter {
    private List<String> fruitList;
    private List<String> vegetableList;
    private List<String> seedList;

    public ViewPagerProductAdapter(@NonNull Buyer_HomeFragment fa) {
        super(fa);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        switch (position) {
            case 0:
                return FruitsFragment.newInstance(fruitList);
            case 1:
                return VegetableFragment.newInstance(vegetableList);
            case 2:
                return SeedFragment.newInstance(seedList);
            default:
                return new Fragment(); // 默认返回一个空Fragment
        }
    }

    @Override
    public int getItemCount() {
        // 返回Tab的数量
        return 3;
    }

    // 为每个列表设置数据的方法
    public void setFruitList(List<String> fruitList) {
        this.fruitList = fruitList;
    }

    public void setVegetableList(List<String> vegetableList) {
        this.vegetableList = vegetableList;
    }

    public void setSeedList(List<String> seedList) {
        this.seedList = seedList;
    }

}